<?
###########################################
#-----------Users login system------------#
###########################################
/*=========================================\
Author      :  Mohammed Ahmed(M@@king)    \\
Version     :  1.0                        \\
Date Created:  Aug 20  2005               \\
----------------------------              \\
Last Update:   August 22 2005             \\
----------------------------              \\
Country    :   Palestine                  \\
City       :   Gaza                       \\
E-mail     :   m@maaking.com              \\
MSN        :   m@maaking.com              \\
AOL-IM     :   maa2pal                    \\
WWW        :   http://www.maaking.com     \\
Mobile/SMS :   00972-599-622235           \\
                                          \\
===========================================\
------------------------------------------*/
//skip the config file if somebody call it from the browser.
if (eregi("config.php", $_SERVER['SCRIPT_NAME'])) {
    Header("Location: index.php"); die();
}

//your databse hostname.
$dbhost = "localhost";
//your database username.
$dbuname = "";
//your db password
$dbpass = "";
$dbname = "database_name_here";
//don't change unless you change this value in the db.
$prefix = "maaking";

//change this
$site_name  = "maaking.com user login system";
$site_email = "m@maaking.com";
$site_url = "http://www.maaking.com/";

include("mysql.class.php");
$db = new sql_db($dbhost, $dbuname, $dbpass, $dbname, false);
if(!$db->db_connect_id) {
      include("header.php");

      echo "<br><font color=red><h3><br><center>Error:</b><br><hr><br>
            <b>Connection to database faild</center>
            <br><br><br><br><br><br><br><br><br>";

      include("footer.php");
      exit();
}


//global function for checkig user is logged in or not.
//you will notice we will use it everwhere in the script.
function is_logged_in($user) {
    global $db,$prefix;

    if(!is_array($user)) {

	$user = explode("|", base64_decode($user));
        $uid = "$user[0]";
	$pwd = "$user[2]";
    } else {
        $uid = "$user[0]";
	$pwd = "$user[2]";
    }
    $uid = addslashes($uid);
        $uid = intval($uid);
    if ($uid != "" AND $pwd != "") {
        $result = mysql_query("SELECT password FROM ".$prefix."_users WHERE userid='$uid'");
	$row = mysql_fetch_array($result);
        $pass = $row['password'];
	if($pass == $pwd && $pass != "") {

           return 1;
	}
    }
    return 0;
}

?>
